#!/bin/sh
# bash_static

. ../../func

URL=http://ftp.gnu.org/gnu/bash
SRC=bash
PKG=bash_static
VER=4.4.18
COMP=tar.gz
DESC=""
DEPS=
CAT=BuildingBlock
CWD=`pwd`

build() {
	cd ${SRC}-${VER}
	echo "Applying patches..."
	ls ../patches/* 2>/dev/null | while read file ; do
		patch -p0 < $file
	done
	opts="--prefix=/usr
--disable-nls
--disable-net-redirections
--enable-static-link
--without-bash-malloc" #--disable-readline
	_configure
	_make ${MKFLG} LDFLAGS=-static
	[ -f $SRC ] || exit_error 1
	install -d -m 0755 $CWD/${PKG}-${VER}-${ARCH}/bin
	_install $SRC $CWD/${PKG}-${VER}-${ARCH}/bin
	cd -
}

package() {
	# add this recipe
	install -d -m 0755 ./${PKG}-${VER}-${ARCH}/build
	cat ${PKG}.petbuild > ./${PKG}-${VER}-${ARCH}/build/$PKG-build-recipe
	# move, don't package
	cp -a --remove-destination ./${PKG}-${VER}-${ARCH}/* ../../00_${ARCH}
	rm -r ${SRC}-${VER}
	rm -r ${PKG}-${VER}-${ARCH}
	echo "moved to initrd"
	echo "done!"
}

# main
retrieve ${SRC}-${VER}.${COMP}
[ "$DLD_ONLY" = "yes" ] && exit
extract ${SRC}-${VER}.${COMP}
build
package

